<template>
	<view class=" baf6" style="height: calc(100vh - 44rpx);overflow-y: auto;background-color: #f1f9ff;">
		<view class="bacnone2 a" style="padding: 0 30rpx;">
			<view class="sousuobyz disbetweena">
				<u-search @search="searchs" v-model="ProductName" placeholder="请输入体检项目关键字" bg-color="#ffffff"
					:clearabled="true" :show-action="false" @custom="searchs"></u-search>
				<view class="bdss  bacnone2 text0" @click="searchs">
					搜索
				</view>
			</view>
		</view>
		<view class="neirong diswc baf6">
			<view class="listconent ">
				<view class="mains borbottmq" v-for="(item,index) in girdlist" :key="index">
					<view :class="girdlist[index].TJCategoryId==indexid?'show bacnone2':''" @click="isShow(item.TJCategoryId)">
						<span class="ftypespan">{{item.TJName}}</span>
					</view>
				</view>
			</view>
			<view class="right">
				<view class="" style="padding: 10rpx;color: gray;">
					自选项目里已包含必检项目
				</view>
				<view class="box pt" v-for="(item,index) in data" :key="index" @click="anorder(item.TJTestId)">
					<image :src="item.TJMainImg" class="imgbox" mode=""></image>
					<view class="imgtext">
						<span class="text1 " style="padding: 5rpx 0;">{{item.TJName}}</span>
						<!-- <span class="gray font25" style="padding: 5rpx 0;">{{item.TJDescription}}</span> -->
						<view class="disbetween"  style="padding: 10rpx 0;">
							<span class="color1" style="font-weight: bold;">￥ {{item.TJPrice}}</span>
							<!-- <view class="yyk bacnone2">
								<view class="" style="color: white;">
									预约
								</view>
							</view> -->
						</view>
					</view>
				</view>
				<span @click="getlist"><u-loadmore :status="loadStatus" /></span>
			</view>

		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				searchstyle: {
					color: '#ffffff'
				},
				data: [
				],
				
				scrollTop: 0,
				showtext: false,
				indexid: '',
				index: 0,
				loadStatus: 'loadmore',
				page: 1,
				rows: 10,
				flowList: [],
				Departmen: [],
				keyword: '',
				girdlist: [],
				NurseDeptId: '',
				CategoryId: '',
				ProductName: '',
				meno: '',
				TJChildId:''
			}
		},
		onLoad: function(option) {
			// console.log("item",JSON.parse(option.TJChildId))
			// console.log("item",option.TJChildId)
			this.TJChildId=option.TJChildId
			// this.NurseDeptId = option.NurseDeptId
			// this.CategoryId = option.CategoryId
			// this.isShow()
			this.getCategory()
		},
		onReachBottom() {
			// this.getlist()
		},
		methods: {
			searchs(e) {
				console.log("搜索", e)
				// this.ProductName=e
				// this.getrow()
			},
			async getrow() {
				uni.showLoading({
					title: '请稍后',
					mask: true
				});
				this.$request("TJCategory", "GetTJTest", {
					TJCategoryId:this.indexid
				}).then(res => {
					console.log("商品列表", res)
					this.data = []
					if (res.code == 1) {
						this.data = res.data
						let leng = res.data.length
						if (leng % 10 == 0) {
							this.loadStatus = "loadmore"
						}
						if (leng % 10 > 0) {
							this.loadStatus = "nomore"
						}
						uni.hideLoading();
					} else {
						uni.hideLoading();
						uni.showToast({
							title: res.msg,
							icon: 'none',
							duration: 2000
						});
					}
				})
			},
			getCategory() {
				uni.showLoading({
					title: '请稍后',
					mask: true
				});
				this.$request("TJCategory", "GetTJCategory").then(res => {
					// console.log("体检类别", res)
					if (res.code == 1) {
						this.girdlist = res.data
						this.indexid=this.girdlist[0].TJCategoryId
						console.log("this.indexid",this.girdlist)
						
						uni.hideLoading();
						this.getrow()
					} else {
						uni.hideLoading();
						uni.showToast({
							title: res.msg,
							icon: 'none',
							duration: 2000
						});
					}
				})
			},
			GetTJTest() {
				uni.showLoading({
					title: '请稍后',
					mask: true
				});
				this.$request("TJCategory", "GetTJTest",
					{TJCategoryId:this.indexid}
				).then(res => {
					console.log("体检套餐", res)
					if (res.code == 1) {
						
						uni.hideLoading();
					} else {
						uni.hideLoading();
						uni.showToast({
							title: res.msg,
							icon: 'none',
							duration: 2000
						});
					}
				})
			},
			anorder(TJTestId) {
				uni.navigateTo({
					url: `/pages/project/projectdetil?TJTestId=${TJTestId}&TJChildId=${this.TJChildId}`
				})
			},
			getlist() {
				this.rows += 6
				this.status = "loading"
				this.getrow()
			},
			isShow(id) {
				this.indexid = id
				this.CategoryId = id
				this.getrow();
			},
			fanhui() {
				uni.navigateBack()
			}
		}
	}
</script>

<style>
	@import './project.css';
</style>